<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form ">

    <div class="layui-form-item">
        <label class="layui-form-label required">电影名</label>
        <div class="layui-input-block">
            <input type="text" name="sName" lay-verify="required" lay-reqtext="电影名不能为空" placeholder="请输入电影名" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">导演</label>
        <div class="layui-input-block">
            <input type="text" name="sDirector"  placeholder="请输入导演" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">演员</label>
        <div class="layui-input-block">
            <input type="text" name="sActor" placeholder="请输入演员" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">海报</label>
        <button type="button" class="layui-btn" id="picSrc">
                <i class="layui-icon">&#xe67c;</i>上传海报
        </button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评分</label>
        <div class="layui-input-block">
            <select name="sRate" lay-verify="required">
                <option value="">暂无评分</option>
                <option value="1">1星</option>
                <option value="2">2星</option>
                <option value="3">3星</option>
                <option value="4">4星</option>
                <option value="5">5星</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">日期</label>
        <div class="layui-inline"> <!-- 注意：这一层元素并不是必须的 -->
            <input type="text" placeholder="yyyy-MM-dd" class="layui-input" id="sDate">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类别</label>
        <div class="layui-input-block">
            <select name="typeId" lay-verify="required">
                <option value="">请选择</option>
                <option value="16">剧情</option>
                <option value="24">动作</option>
                <option value="22">爱情</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">点击量</label>
        <div class="layui-input-block">
            <input type="text" name="sHit"  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">简介</label>
        <div class="layui-input-block">
            <textarea name="sContent" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form','upload','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            upload = layui.upload,
            laydate = layui.laydate,
            $ = layui.$;
        //执行实例
        var uploadInst = upload.render({
            elem: '#spic' //绑定元素
            ,url: '/upload/' //上传接口
            ,done: function(res){
                //上传完毕回调
            }
            ,error: function(){
                //请求异常回调
            }
        });
        laydate.render({
            elem: '#sdate' //指定元素
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {

                // 关闭弹出层
                layer.close(index);

                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);

            });
            //发送请求
            $.post("/subject/add",data.field,function (result) {
                if (result.success){
                    //成功
                    layer.alert(result.message,{icon:1});
                    //刷新当前数据表格
                    
                }
            },"json");
            return false;
        });

    });
</script>
</body>
</html>